TOOLPREFIX = riscv32-unknown-elf-
CC = $(TOOLPREFIX)gcc
LD = $(TOOLPREFIX)ld

CFLAGS = -Wall -Werror -fno-omit-frame-pointer
CFLAGS += -mcmodel=medany
CFLAGS += -ffreestanding -fno-common -nostdlib -mno-relax
CFLAGS += -I.
CFLAGS += -march=rv32g

LDFLAGS = -z max-page-size=4096 -T ulinker.ld

neo: neo.c
	$(CC) $(CFLAGS) -c neo.c -o neo.o
	$(CC) $(CFLAGS) -c syscall.S -o syscall.o
	$(CC) $(CFLAGS) -c ulib.c -o ulib.o
	$(LD) $(LDFLAGS) -o neo ulib.o neo.o syscall.o

clean: 
	rm neo neo.o syscall.o ulib.o